package my.base.util;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.google.common.base.Preconditions;


/**
 * 
 * @author fanhongjie
 *
 */
public final class FileUtil {
	private static final Log logger = LogFactory.getLog(FileUtil.class);
	/**
	 * 获取Class的路径
	 * @param cls 指定的Class对象
	 * @return Class的路径，如果Class没有指定的package，则返回"";
	 */
	public static String getPath(Class<?> cls) {
		Preconditions.checkNotNull(cls, "cls should not be null!");
		Package pkg = cls.getPackage();
		String pkgName = null;
		if (pkg == null) {
			pkgName =  "";
		} else {
			pkgName = pkg.getName();
			pkgName = pkgName.replaceAll("\\.", "/");
		}
		logger.debug(pkgName);
		return pkgName;
	}
}
